/**
 * Music.java
 *
 *
 * $LastChangedBy: allen $
 * $LastChangedDate: 2007-11-21 18:32:16 +0800 $
 * $Revision: 1225 $
 */
package com.myspace.domain;

import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

@Entity(name = "Music")
public class Music extends DomainObject {

	private static final long serialVersionUID = 2007111286L;

	private Long id;

	private String name;

	private String category;

	private String musicPath;

	private String note;

	private Date createDate;

	private Long userId;

	public Music(String name, String category, String musicPath, String note,
			Date createDate) {
		this.name = name;
		this.category = category;
		this.musicPath = musicPath;
		this.note = note;
		this.createDate = createDate;
	}

	public Music() {
	}

	public Music(String name, String category, String musicPath, Date createDate) {
		this.name = name;
		this.category = category;
		this.musicPath = musicPath;
		this.createDate = createDate;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "seq_music")
	@SequenceGenerator(name = "seq_music", sequenceName = "SEQ_MUSIC")
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Basic(fetch = FetchType.EAGER)
	@Column(name = "NAME")
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "CATEGORY")
	public String getCategory() {
		return this.category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	@Basic(fetch = FetchType.EAGER)
	@Column(name = "MUSIC_PATH")
	public String getMusicPath() {
		return this.musicPath;
	}

	public void setMusicPath(String musicPath) {
		this.musicPath = musicPath;
	}

	@Column(name = "NOTE")
	public String getNote() {
		return this.note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	@Column(name = "CREATE_DATE")
	@Temporal(TemporalType.DATE)
	public Date getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	// @OneToMany
	// public List getMusicComments() {
	// return this.musicComments;
	// }

	public String toString() {
		return new ToStringBuilder(this).append("id", getId()).toString();
	}

	public boolean equals(Object other) {
		if (!(other instanceof Music))
			return false;
		Music castOther = (Music) other;
		return new EqualsBuilder().append(this.getId(), castOther.getId())
				.isEquals();
	}

	public int hashCode() {
		return new HashCodeBuilder().append(getId()).toHashCode();
	}

	@Column(name = "USER_ID")
	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	@Override
	@Transient
	public boolean isPersistence() {
		return id != null;
	}

}
